﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Data.SqlClient;

namespace TextMIS
{
    public partial class frmFillIn : Form
    {
        public frmFillIn()
        {
            InitializeComponent();
        }
        public static string userName;
        SqlConnection conn;
        SqlCommand com;

        private void frmFillIn_Load(object sender, EventArgs e)
        {
            conn = new
             SqlConnection(frmLogin.SQLstr);
            userName = frmLogin.userName;



            this.cbxSex.Items.Add("男");
            this.cbxSex.Items.Add("女");
        }

        private void btnRepeat_Click(object sender, EventArgs e)
        {
            txtRegisNum.Clear();
            txtName.Clear();
            cbxSex.Text = "";
            txtTel.Clear();
            txtAddress.Clear();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {

                com = new SqlCommand("update PatientInfo set RegisterID = '" + 
                    txtRegisNum.Text.Trim() + "',Pname = '" + 
                    txtName.Text.Trim() + "',Psex = '" + cbxSex.Text.Trim() + "',Pphone = '" +
                    txtTel.Text.Trim() + "',Paddress = '" + txtAddress.Text.Trim() + "'where Username = '" + userName + "'", conn);

                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }

                com.ExecuteNonQuery();
                conn.Close();
                MessageBox.Show("填写成功！");

        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
